package org.zn.etl.controller;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zn.etl.datasource.DataSourceFactoryHolder;
import org.zn.etl.datasource.SpringDataSourceFactory;
import org.zn.etl.datasource.entity.DataSourceInfo;
import org.zn.etl.jdbc.Upsert;
import org.zn.etl.job.dao.DataMappingMapper;
import org.zn.etl.job.dao.DataSourceInfoMapper;
import org.zn.etl.job.entity.po.DataMappingPo;
import org.zn.etl.job.entity.po.DataSourceInfoPo;
import org.zn.etl.misc.DataSourceInfo2ConfigMap;
import org.zn.etl.misc.ErrorMessageFilterHelper;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * @author zhounan
 *
 */
@Slf4j
@RestController
@RequestMapping()
public class TestController {
	
	@Autowired
	private ObjectMapper  objectMapper;
	
	
	@RequestMapping("/vue-element-admin/user/login")
	public Map test() throws JsonMappingException, JsonProcessingException{
		
		log.debug("debug test");

		String login="{\"code\":20000,\"data\":{\"token\":\"admin-token\"}}";
		
		return objectMapper.readValue(login, Map.class);
	}
	
	
	@RequestMapping("/vue-element-admin/user/info")
	public Map token() throws JsonMappingException, JsonProcessingException{
		
		log.debug("debug test");
		
		
		

		String login="{ \"code\": 20000,\n"
				+ "    \"data\": {\n"
				+ "        \"roles\": [\n"
				+ "            \"admin\"\n"
				+ "        ],\n"
				+ "        \"introduction\": \"I am a super administrator\",\n"
				+ "        \"avatar\": \"https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif\",\n"
				+ "        \"name\": \"Super Admin\"\n"
				+ "    }}";
		
		return objectMapper.readValue(login, Map.class);
	}

	
	@GetMapping("/filterError")
	public boolean filterError(@RequestBody Map<String, String>  req) throws Exception{
	
		String msg=req.get("errorMsg");

		return ErrorMessageFilterHelper.getFilter().FilterMessage(msg);
		
	}
	


}
